(function() {
  /*
  this is the basic loader for tree
  */

  var clone_object, drag_over, funcs;
  var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    function ctor() { this.constructor = child; }
    ctor.prototype = parent.prototype;
    child.prototype = new ctor;
    child.__super__ = parent.prototype;
    return child;
  }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  window.include = function(name) {};
  window.tree = {};
  /*
  the BaseObject is like Object in Java the base class for all tree classes
  
  it defines these methods:
      disconnet(callback)
      emit(name, args)
      connect(name, callback)
  */

  clone_object = function(obj) {
    var c;
    c = (function() {})();
    c.prototype = obj;
    return new c;
  };
  tree.BaseObject = (function() {
    function BaseObject() {
      this.eventmap = {};
    }
    BaseObject.prototype.connect = function(name, callback, args) {
      if (!(this.eventmap[name] != null)) {
        return this.eventmap[name] = [[callback, args]];
      } else {
        return this.eventmap[name].push([callback, args]);
      }
    };
    BaseObject.prototype.disconnect = function(callback) {
      var field, part, tmp, _results;
      tmp = this.eventmap;
      this.eventmap = {};
      _results = [];
      for (field in tmp) {
        part = tmp[field];
        _results.push((function(field, part) {
          var item, _i, _len, _results2;
          _results2 = [];
          for (_i = 0, _len = part.length; _i < _len; _i++) {
            item = part[_i];
            _results2.push((function(item) {
              var func;
              func = item[0];
              if (func !== callback) return this.eventmap[field] = callback;
            })(item));
          }
          return _results2;
        })(field, part));
      }
      return _results;
    };
    BaseObject.prototype.emit = function(name, event) {
      var args, callback, part, parts, _i, _len, _results;
      parts = this.eventmap[name];
      if (!parts) return;
      _results = [];
      for (_i = 0, _len = parts.length; _i < _len; _i++) {
        part = parts[_i];
        callback = part[0];
        args = part[1];
        _results.push(callback ? callback(this, event, args) : void 0);
      }
      return _results;
    };
    BaseObject.prototype.clone = function() {
      return clone_object(this);
    };
    return BaseObject;
  })();
  tree.using = function(name) {
    /*
        Copy the namespace into the global namespace. Be careful, this can pollute the global namespace and objects
        might be overridden.
    */

    var parts = name.split('.');
    var before = window;
    for(var i=0; i<parts.length; i++)
    {
        var part = parts[i];
        if(before[part] == null || before[part].prototype == null)
            if(before[part] == null)
            {
                throw new TypeError("namespace " + part + " doesnt exist");
            }
            else
            {
                before = before[part];
            }
        else
        {
            throw new TypeError(part + " is a class");
        }
        for(field in before)
        {
            window[field] = before[field];
        }
    };    return null;
  };
  tree.io = {};
  tree.ui = {};
  funcs = [];
  tree.ui.add_onload = function(func) {
    return funcs.push(func);
  };
  /*
  window.onload = () ->
      for func in funcs
          func()
  */

  /*
  set up drag and drop
  */

  drag_over = function(event) {
    event.preventDefault();
    return false;
  };
  tree.ui.add_onload(function() {
    var drop;
    drop = function(event) {
      var data, htmlelem;
      data = tree.io.formats.json.load(event.dataTransfer.getData('text/plain'));
      htmlelem = document.getElementById(data.id);
      htmlelem.style.left = (event.clientX + data.x) + 'px';
      htmlelem.style.top = (event.clientY + data.y) + 'px';
      event.preventDefault();
      return false;
    };
    document.body.addEventListener('dragover', drag_over, false);
    return document.body.addEventListener('drop', drop, false);
  });
  tree.ressources = {};
  tree.io.formats = {};
  /*
  all modules have a simple api:
  
  load:
      this function makes a javascript object of a string in a specific format
      
  dump:
      make a string from a javascript object
  */

  tree.persistence = {};
  tree.unittest = {};
  include('/tree/unittest/testcase.js');
  include('/tree/unittest/test_suite.js');
  include('/tree/unittest/main.js');
  include('/tree/unittest/loggers/loggers.js');
  tree.io.rpc = {};
  /*
  Proxy for rpc server methods.
  
  
  events: ['error-occured']
  
  This class is an abstract class. Subclasses must override:
      
      string create_request(string name, params[])
      
      object parse_response(string data)
  */

  tree.io.rpc.Proxy = (function() {
    __extends(Proxy, tree.BaseObject);
    function Proxy(url, content_type) {
      var _ref;
      this.url = url;
      Proxy.__super__.constructor.apply(this, arguments);
      this.content_type = content_type;
      if ((_ref = this.content_type) == null) {
        this.content_type = tree.io.ajax.DATA_FORMAT.plain;
      }
    }
    Proxy.prototype.parse_response = function(data) {
      throw new 'method create_request not implemented';
    };
    Proxy.prototype.create_request = function(data) {
      throw new 'method create_request not implemented';
    };
    Proxy.prototype.call_method = function(name, params) {
      var request, response;
      request = this.create_request(name, params);
      response = tree.io.ajax.xhr(this.url, {
        async: false,
        type: tree.io.ajax.REQUEST_METHODS.POST,
        raw_data: request
      });
      return this.parse_response(response);
    };
    return Proxy;
  })();
  /*
  This is the base class for all widgets. It should not be used directly and it will not work as expected.
  You have to create the htmlelem attribute directly in the constructor of your class or in the attributes.
  
  events: [    'button-press', //This event is triggered when a key or mouse button is pressed. The key attribute of the event args is the pressed key
                  'button-release', // This event is triggered when a key or mouse button is released
                  'focused', // This event is triggered when the widget is focused
                  'focus-lost', // This event is triggered when the widget looses focus
                  'clicked', //This event is triggered when the user clicks on the widget
                  'double-clicked', // This event is triggered when the user double clicks on the widget
                  'mouse-move',
                  'mouse-in', 
                  'mouse-out'],
  */

  tree.ui.Widget = (function() {
    __extends(Widget, tree.BaseObject);
    function Widget() {
      Widget.__super__.constructor.apply(this, arguments);
      this.active = true;
      this.hidden = false;
      this.tooltip = '';
      this.border = 0;
      this.exposed = false;
      this.htmlelem = null;
      this.styles = {};
    }
    /*
        set a style attribute to your widget, the identifier is the css identifier
    */

    Widget.prototype.set_style = function(identifier, value) {
      return this.htmlelem.style[identifier] = value;
    };
    /*
        set the widgets height in pixel
    */

    Widget.prototype.set_height = function(height) {
      if (this.htmlelem) {
        return this.htmlelem.style.height = height + 'px;';
      } else {
        throw new TypeError('no html elem set');
      }
    };
    /*
        set the widgets width in pixel
    */

    Widget.prototype.set_width = function(width) {
      if (this.htmlelem) {
        return this.htmlelem.style.width = width + 'px';
      } else {
        throw new TypeError('no html elem set');
      }
    };
    /*
        set the width of the border
        it is solid, if you dont want it to be solid, look for tree.ui.Widget.set_style
    */

    Widget.prototype.set_border_width = function(border) {
      if (this.htmlelem) {
        this.htmlelem.style.borderStyle = 'solid';
        return this.htmlelem.style.borderWidth = border + 'px';
      } else {
        throw new TypeError('no html elem set');
      }
    };
    /*
        get the width of the border
    */

    Widget.prototype.get_border_width = function() {
      return this.htmlelem.style.borderWidth;
    };
    /*
        render the widget and a lot of signals are connected too
    */

    Widget.prototype.show = function() {
      this.htmlelem.onclick = __bind(function(evt) {
        return this.emit('clicked', {});
      }, this);
      this.htmlelem.onkeyup = __bind(function(evt) {
        return this.emit('button-release', {});
      }, this);
      this.htmlelem.onkeydown = __bind(function(evt) {
        var key;
        key = String.fromCharCode(evt.which);
        return this.emit('button-press', {
          key: key
        });
      }, this);
      this.htmlelem.onfocus = __bind(function(evt) {
        return this.emit('focused', {});
      }, this);
      this.htmlelem.onblur = __bind(function(evt) {
        return this.emit('focus-lost', {});
      }, this);
      this.htmlelem.onmouseover = __bind(function(evt) {
        return this.emit('mouse-in', {});
      }, this);
      this.htmlelem.onmouseout = __bind(function(evt) {
        return this.emit('mouse-out', {});
      }, this);
      this.htmlelem.onmousemove = __bind(function(evt) {
        return this.emit('mouse-move', {});
      }, this);
      this.exposed = true;
      return this.htmlelem;
    };
    /*
        hide the widget
    */

    Widget.prototype.hide = function() {
      if (this.htmlelem) {
        return this.htmlelem.style.visibility = 'hidden';
      } else {
        throw new TypeError('no html elem set');
      }
    };
    /*
        show the widget after hiding
    */

    Widget.prototype.unhide = function() {
      if (this.htmlelem) {
        return this.htmlelem.style.visibility = 'visible';
      } else {
        throw new TypeError('no html elem set');
      }
    };
    Widget.prototype.activate = function() {};
    Widget.prototype.is_focus = function() {};
    Widget.prototype.modify_fg = function(color) {
      if (this.htmlelem) {
        return this.htmlelem.style.color = color;
      } else {
        throw new TypeError('no html elem set');
      }
    };
    Widget.prototype.modify_bg = function(color) {
      if (this.htmlelem) {
        return this.htmlelem.style.backgroundColor = color;
      } else {
        throw new TypeError('no html elem set');
      }
    };
    Widget.prototype.set_tooltip = function(tooltip) {
      if (this.htmlelem) {
        return this.htmlelem.title = tooltip;
      } else {
        throw new TypeError('no html elem set');
      }
    };
    Widget.prototype.get_tooltp = function() {
      return this.tooltip;
    };
    Widget.prototype.set_geom = function(rect) {
      this.set_style('position', 'absolute');
      this.set_style('left', rect.left() + 'px');
      this.set_style('width', rect.width + 'px');
      this.set_style('top', rect.top() + 'px');
      this.set_style('height', rect.height + 'px');
      return this.geom = rect;
    };
    return Widget;
  })();
  /*
  
  events: ['added', 'removed'],
  */

  tree.ui.Container = (function() {
    __extends(Container, tree.ui.Widget);
    function Container() {
      Container.__super__.constructor.apply(this, arguments);
      this.children = [];
    }
    Container.prototype.get_children = function() {
      return this.children;
    };
    Container.prototype.add = function(child) {
      this.children.push(child);
      child.parent = this;
      return this.emit('update', {});
    };
    Container.prototype.remove = function(child) {
      this.children = this.children.remove(child);
      return this.emit('update', {});
    };
    return Container;
  })();
  tree.unittest.loggers = {};
  include('/tree/unittest/loggers/console_logger.js');
  /*
  
  The VBox widget aligns widgets in a vertical order.
  */

  tree.ui.VBox = (function() {
    __extends(VBox, tree.ui.Container);
    function VBox() {
      this.added = __bind(this.added, this);      VBox.__super__.constructor.apply(this, arguments);
      this.connect('added', this.added);
      this.htmlelem = document.createElement('table');
      this.htmlelem.className = 'tree-vbox-layout';
    }
    VBox.prototype.added = function(evt) {};
    VBox.prototype.show = function() {
      var child, td, tr, _i, _len, _ref;
      VBox.__super__.show.call(this, this);
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        tr = document.createElement('tr');
        td = document.createElement('td');
        tr.appendChild(td);
        td.appendChild(child.show());
        this.htmlelem.appendChild(tr);
      }
      return this.htmlelem;
    };
    return VBox;
  })();
  tree.io.rpc.JSON_Proxy = (function() {
    __extends(JSON_Proxy, tree.io.rpc.Proxy);
    /*
    	Proxy for xmlrpc server methods.
    	For the standard look here: http://www.xmlrpc.com/spec.
    	
    	It also needs theese extensions:
    	
    	http://xmlrpc-c.sourceforge.net/introspection.html
    	http://ontosys.com/xml-rpc/extensions.php
    	
    	events: ['error-occured'],
    */

    function JSON_Proxy(url, version) {
      JSON_Proxy.__super__.constructor.call(this, url);
      if (!version) version = '1.0';
      this.version = version;
      this.content_type = tree.io.ajax.DATA_FORMAT.json;
    }
    JSON_Proxy.prototype.parse_response = function(data) {
      var response;
      response = tree.io.formats.json.load(data);
      /*        
      example: { "result": "Hello JSON-RPC", "error": null, "id": 1}
      */

      if (this.version === '1.0') {
        if (response.error) {
          this.emit('error-occured', {
            error: response.error
          });
          return;
        }
        return response.result;
        /*
                    { 
                        "version": "1.1", 
                        "result": "done", 
                        "error": null, 
                        "id": "194521489"
                    }
        */

      } else if (this.version === '1.1') {
        if (response.version !== '1.1') {
          throw new ("invalid version in response: " + response.version);
        }
        if (response.error) {
          this.emit('error-occured', {
            error: response.error
          });
          return;
        }
        return response.result;
      } else if (this.version === '2.0') {} else {
        throw "invalid json-rpc version: " + this.version;
      }
    };
    JSON_Proxy.prototype.create_request = function(name, params) {
      var request;
      request = {};
      /*
              example: { "method": "echo", "params": ["Hello JSON-RPC"], "id": 1}
      */

      if (this.version === '1.0') {
        request.id = 1;
        request.method = name;
        request.params = params;
        /*
                    { 
                        "version": "1.1", 
                        "method": "confirmFruitPurchase", 
                        "id": "194521489", 
                        "params": 
                        [ 
                            [ "apple", "orange", "pear" ], 
                            1.123 
                        ]
                    }
        */

      } else if (this.version === '1.1') {
        request.id = 1;
        request.version = '1.1';
        request.method = name;
        request.params = params;
      } else if (this.version === '2.0') {} else {
        throw "invalid json-rpc version: " + this.version;
      }
      return tree.io.formats.json.dump(request);
    };
    return JSON_Proxy;
  })();
  tree.ui.Image = (function() {
    __extends(Image, tree.ui.Widget);
    function Image(src) {
      Image.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('img');
      this.htmlelem.src = src;
    }
    return Image;
  })();
  /*
  use table to render
  */

  tree.ui.TreeView = (function() {
    __extends(TreeView, tree.ui.Widget);
    function TreeView() {
      TreeView.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('ul');
      this.htmlelem.className = 'tree-treeview';
      this.data = {};
    }
    TreeView.prototype.set_data = function(data) {
      var child, children, create_elems, self, _i, _len, _results;
      this.data = data;
      self = this;
      create_elems = function(data, keys) {
        var a, child, children, key, li, lis, span, table, tb, td1, td2, tr, ul, _i, _len;
        if (keys == null) keys = [];
        lis = [];
        for (key in data) {
          li = document.createElement('li');
          span = document.createElement('span');
          span.className = 'tree-treeview-item';
          span.innerHTML = key;
          span.keys = tree.io.formats.json.dump(keys.concat(key));
          span.onclick = function() {
            if (self.selected != null) {
              self.selected.className = 'tree-treeview-item';
            }
            this.className = 'tree-treeview-item-selected';
            self.selected = this;
            return self.emit('row-activated', {
              path: tree.io.formats.json.load(this.keys)
            });
          };
          table = document.createElement('table');
          table.className = 'tree-treeview-cell';
          tb = document.createElement('tbody');
          tr = document.createElement('tr');
          tb.appendChild(tr);
          table.appendChild(tb);
          table.style.width = 'auto';
          table.style.height = 'auto';
          td1 = document.createElement('td');
          td1.className = 'tree-treeview-button';
          td2 = document.createElement('td');
          tr.appendChild(td1);
          tr.appendChild(td2);
          a = document.createElement('a');
          li.appendChild(table);
          td1.appendChild(a);
          td2.appendChild(span);
          a.innerHTML = '&nbsp;';
          if (data[key]) {
            a.innerHTML = '+';
            a.style.cursor = 'pointer';
            ul = document.createElement('ul');
            ul.style.display = 'none';
            children = create_elems(data[key], keys.concat([key]));
            for (_i = 0, _len = children.length; _i < _len; _i++) {
              child = children[_i];
              ul.appendChild(child);
            }
            li.appendChild(ul);
            a.onclick = function() {
              var childNode, _j, _k, _len2, _len3, _ref, _ref2, _results, _results2;
              if (this.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].style.display === 'none') {
                this.innerHTML = '-';
                _ref = this.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes;
                _results = [];
                for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
                  childNode = _ref[_j];
                  if (childNode.nodeName !== 'UL') continue;
                  _results.push(childNode.style.display = 'block');
                }
                return _results;
              } else {
                this.innerHTML = '+';
                _ref2 = this.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes;
                _results2 = [];
                for (_k = 0, _len3 = _ref2.length; _k < _len3; _k++) {
                  childNode = _ref2[_k];
                  if (childNode.nodeName !== 'UL') continue;
                  _results2.push(childNode.style.display = 'none');
                }
                return _results2;
              }
            };
          }
          lis.push(li);
        }
        return lis;
      };
      children = create_elems(data);
      _results = [];
      for (_i = 0, _len = children.length; _i < _len; _i++) {
        child = children[_i];
        _results.push(this.htmlelem.appendChild(child));
      }
      return _results;
    };
    TreeView.prototype.show = function() {
      TreeView.__super__.show.call(this, this);
      return this.htmlelem;
    };
    return TreeView;
  })();
  tree.io.formats.csv = {};
  tree.io.formats.csv.load = function(data) {
    var line, lines, seperator, vals, values, _i, _len;
    values = [];
    seperator = ',';
    lines = data.split('\n');
    for (_i = 0, _len = lines.length; _i < _len; _i++) {
      line = lines[_i];
      vals = line.split(seperator);
      values.push(vals);
    }
    return values;
  };
  tree.io.formats.csv.dump = function(data) {
    var col, ret, row, seperator, _i, _j, _len, _len2;
    seperator = ',';
    ret = '';
    for (_i = 0, _len = data.length; _i < _len; _i++) {
      row = data[_i];
      for (_j = 0, _len2 = row.length; _j < _len2; _j++) {
        col = row[_j];
        ret += col;
        ret += seperator;
      }
      ret += '\n';
    }
    return ret;
  };
  /*
  events: ['update']
  */

  tree.ui.DrawingArea = (function() {
    __extends(DrawingArea, tree.ui.Widget);
    function DrawingArea() {
      this.update_callback = __bind(this.update_callback, this);      DrawingArea.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('canvas');
      this.timer = setInterval(callback, 100);
    }
    DrawingArea.prototype.update_callback = function() {
      var context;
      context = this.htmlelem.getContext('2d');
      return this.emit('update', {
        widget: _this,
        context: context
      });
    };
    DrawingArea.prototype.get_context = function() {
      return this.htmlelem.getContext('2d');
    };
    DrawingArea.prototype.stop_drawing = function() {
      return clearInterval(this.timer);
    };
    return DrawingArea;
  })();
  tree.ressources.Strings = (function() {
    function Strings() {
      var json, string_node;
      string_node = document.getElementById('strings');
      json = string_node.innerHTML;
      this.data = tree.io.formats.json.load(json);
    }
    Strings.prototype.get_string = function(name) {
      return this.data[name];
    };
    return Strings;
  })();
  tree.io.ajax = {};
  tree.io.ajax.DATA_FORMAT = {
    plain: 0,
    json: 1,
    xml: 2,
    html: 3,
    csv: 4
  };
  tree.io.ajax.REQUEST_METHODS = {
    GET: 0,
    POST: 1
  };
  tree.io.ajax.xhr = function(url, args) {
    /*
    
        get data by ajax
    
        the url must be in the same domain
    
        args:
    
            async: bool
            
            method: tree.io.ajax.REQUEST_METHODS.(GET|POST)
            
            complete: function(data){}
            this parameter is only used if you have an async request
            
            type: tree.io.ajax.DATA_FORMAT
            
            data: 
            {
                a: 5,
                b: 6,
            }
            
            raw_data: string
    */

    var async, complete, formdata, http, key, request_type, request_type_string, type, value, _ref;
    http = new XMLHttpRequest();
    request_type = tree.io.ajax.REQUEST_METHODS.GET;
    async = false;
    type = tree.io.ajax.DATA_FORMAT.plain;
    complete = function(data) {};
    if (args.method != null) request_type = args.method;
    if (args.async != null) async = args.async;
    if (args.complete != null) {
      if (!async) throw 'complete only for async calls';
      complete = args.complete;
    }
    if (args.type != null) type = args.type;
    request_type_string = '';
    if (args.request_type === tree.io.ajax.REQUEST_METHODS.GET) {
      request_type_string = 'GET';
    } else {
      request_type_string = 'POST';
    }
    http.open(request_type_string, url, async);
    if (type === tree.io.ajax.DATA_FORMAT.plain) {
      http.setRequestHeader('Content-Type', 'text/plain');
    } else if (type === tree.io.ajax.DATA_FORMAT.xml) {
      http.setRequestHeader('Content-Type', 'text/xml');
    } else if (type === tree.io.ajax.DATA_FORMAT.json) {
      http.setRequestHeader('Content-Type', 'application/json');
    }
    if (async) {
      http.onreadystatechange = (function(evt) {
        if (http.status === 4) {
          if (type === tree.io.ajax.DATA_FORMAT.plain) {
            return complete(http.responseText);
          }
        }
      })(evt);
    }
    formdata = null;
    if (args.data != null) {
      formdata = new FormData();
      _ref = args.data;
      for (key in _ref) {
        value = _ref[key];
        value = params[key];
        formdata.append(key, value);
      }
    } else if (args.raw_data != null) {
      formdata = args.raw_data;
    }
    http.send(formdata);
    if (!async) {
      if (type === tree.io.ajax.DATA_FORMAT.plain) {
        return http.responseText;
      } else if (type === tree.io.ajax.DATA_FORMAT.xml) {
        return http.responseXML;
      } else if (type === tree.io.ajax.DATA_FORMAT.html) {
        return '';
      } else {
        return http.responseText;
      }
    }
  };
  /*
  TODO: add support for browsers that dont support localStorage by using cookies and json instead
  */

  tree.persistence.Storage = (function() {
    __extends(Storage, tree.BaseObject);
    function Storage(app) {
      this.app = app;
      Storage.__super__.constructor.apply(this, arguments);
      if ((localStorage.getItem(this.app)) === null) {
        localStorage.setItem(this.app, tree.io.formats.json.dump({}));
      }
    }
    Storage.prototype.save = function(key, val) {
      var value;
      value = tree.io.formats.json.load(localStorage.getItem(this.app));
      value[key] = val;
      localStorage.setItem(this.app, tree.io.formats.json.dump(value));
      return this.emit('changed', {
        type: 'saved',
        key: key,
        val: val
      });
    };
    Storage.prototype.get_all = function() {
      return tree.io.formats.json.load(localStorage.getItem(this.app));
    };
    Storage.prototype.clear = function() {
      return localStorage.setItem(this.app, tree.io.formats.json.dump({}));
    };
    Storage.prototype.get = function(key) {
      var value;
      value = tree.io.formats.json.load(localStorage.getItem(this.app));
      if (value[key] === null) return '';
      return value[key];
    };
    Storage.prototype.remove = function(key) {
      localStorage.remove(key);
      return this.emit('changed', {
        type: 'removed',
        key: key
      });
    };
    return Storage;
  })();
  String.prototype.replace = function(str1, str2) {
    var c, ret, _i, _len;
    ret = '';
    for (_i = 0, _len = this.length; _i < _len; _i++) {
      c = this[_i];
      ret += c;
      if (ret.substring(ret.length - str1.length) === str1) {
        ret = ret.substring(0, ret.length - str1.length) + str2;
      }
    }
    return ret;
  };
  tree.ui.Statusbar = (function() {
    function Statusbar() {}
    Statusbar.push = function(text) {
      return (document.getElementById('dock')).innerHTML = text;
    };
    return Statusbar;
  })();
  tree.async = {};
  /*
  The HBox widget aligns widgets in a horizontal order.
  */

  tree.ui.HBox = (function() {
    __extends(HBox, tree.ui.Container);
    function HBox() {
      this.added = __bind(this.added, this);      HBox.__super__.constructor.apply(this, arguments);
      this.connect('added', this.added);
      this.htmlelem = document.createElement('table');
      this.htmlelem.setAttribute('class', 'tree-hbox-layout');
    }
    HBox.prototype.added = function(evt) {
      var child, tbody, td, tr, _i, _len, _ref;
      while (this.htmlelem.hasChildNodes()) {
        while (this.htmlelem.childNodes.length >= 1) {
          this.htmlelem.removeChild(this.htmlelem.firstChild);
        }
      }
      tbody = document.createElement('tbody');
      tr = document.createElement('tr');
      tbody.appendChild(tr);
      this.htmlelem.appendChild(tbody);
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        td = document.createElement('td');
        tr.appendChild(td);
        td.appendChild(child.show());
      }
      return this.htmlelem;
    };
    HBox.prototype.show = function() {
      var child, tbody, td, tr, _i, _len, _ref;
      HBox.__super__.show.apply(this, arguments);
      tbody = document.createElement('tbody');
      tr = document.createElement('tr');
      tbody.appendChild(tr);
      this.htmlelem.appendChild(tbody);
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        td = document.createElement('td');
        tr.appendChild(td);
        td.appendChild(child.show());
      }
      return this.htmlelem;
    };
    return HBox;
  })();
  /*
  the testcase is intended for testing javascript code
  
  the api is like the python api: http://docs.python.org/library/unittest.html
  */

  tree.unittest.TestCase = (function() {
    __extends(TestCase, tree.BaseObject);
    function TestCase() {
      var key, value;
      TestCase.__super__.constructor.apply(this, arguments);
      this.logger = new tree.unittest.loggers.ConsoleLogger;
      if (this.setUp) this.setUp();
      this.tests = {};
      for (key in this) {
        value = this[key];
        if (typeof value === 'function' && key.indexOf('test' === 0)) {
          this.tests[field] = this[field];
        }
      }
      this.skip = false;
    }
    TestCase.prototype.add = function() {
      return tree.unittest._suite.add_test(this);
    };
    TestCase.prototype.run = function() {
      var failed, key, test, _ref;
      this.logger.write('started test');
      _ref = this.tests;
      for (key in _ref) {
        test = _ref[key];
        this.logger.write("running test: " + key);
        failed = false;
        try {
          test.apply(this);
        } catch (exc) {
          failed = true;
          this.logger.error("" + key + " failed with exception: " + exc);
        }
        if (!failed) this.logger.write("Test " + key + "  Ok");
        if (this.skip) {
          this.skip = true;
          this.logger.warn('skipping tests');
          return;
        }
      }
      return this.logger.write('test complete');
    };
    TestCase.prototype.assert_equal = function(first, second) {
      if (first !== second) throw 'assert equal failed';
    };
    TestCase.prototype.assert_not_equal = function(first, second) {
      if (first === second) throw 'not assert equal failed';
    };
    TestCase.prototype.assert_true = function(val) {
      if (!val) throw 'assert true failed';
    };
    TestCase.prototype.assert_false = function(val) {
      if (val) throw 'assert false failed';
    };
    TestCase.prototype.assert_is = function(first, second) {
      if (first === second) throw 'assert is failed';
    };
    TestCase.prototype.assert_is_not = function(first, second) {
      if (first !== second) throw 'assert is not failed';
    };
    TestCase.prototype.assert_is_null = function(val) {
      if (val != null) throw 'assert is null failed';
    };
    TestCase.prototype.assert_is_not_null = function(val) {
      if (val === null) throw 'assert is not null failed';
    };
    TestCase.prototype.assert_in = function(arr, elem) {
      if (arr.contains(elem)) throw 'assert in failed';
    };
    TestCase.prototype.assert_not_in = function(arr, elem) {
      if (!arr.contains(elem)) throw 'assert not in failed';
    };
    TestCase.prototype.assert_is_instance = function(obj, cls) {
      if (!obj instanceof cls) throw 'assert is instance failed';
    };
    TestCase.prototype.assert_is_not_instance = function(obj, cls) {
      if (obj instanceof cls) throw 'assert is not instance failed';
    };
    TestCase.prototype.__compare_array = function(list1, list2) {
      var i, _ref;
      if (list1.length !== list2.length) return false;
      for (i = 0, _ref = list1.length; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
        if (list1[i] !== list2[i]) return false;
      }
      return true;
    };
    TestCase.prototype.assert_array_equal = function(list1, list2) {
      if (!(this.__compare_array(list1, list2))) throw 'assert array equal failed';
    };
    TestCase.prototype.assert_array_not_equal = function(list1, list2) {
      if (this.__compare_array(list1, list2)) {
        throw 'assert array not equal failed';
      }
    };
    TestCase.prototype.skip_test = function() {
      return this.skip = true;
    };
    return TestCase;
  })();
  /*
  
  The label displays text or it wraps an image.
  */

  tree.ui.Label = (function() {
    __extends(Label, tree.ui.Widget);
    function Label(text) {
      var _ref;
      this.text = text;
      Label.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('div');
      this.htmlelem.setAttribute('class', 'tree-label');
      if ((_ref = this.text) == null) this.text = '';
      this.has_image = false;
      this.image = null;
      this.htmlelem.innerHTML = this.text;
    }
    Label.prototype.set_text = function(text) {
      this.text = text;
      this.has_image = false;
      this.image = null;
      return this.htmlelem.innerHTML = this.text;
    };
    Label.prototype.get_text = function() {
      return this.text;
    };
    Label.prototype.set_image = function(image) {
      this.image = image;
      this.has_image = true;
      return this.htmlelem.innerHTML = this.image.show();
    };
    Label.prototype.get_size = function() {
      var css_height, css_width, h, w, x, y;
      x = 0;
      y = 0;
      css_width = window.getComputedStyle(this.htmlelem, null).getPropertyValue('font-size');
      w = this.text.length * css_width.substring(0, css_width.length - 2) / 2;
      css_height = window.getComputedStyle(this.htmlelem, null).getPropertyValue('line-height');
      h = css_width.substring(0, css_width.length - 2);
      return new Rect(x, y, w, h);
    };
    Label.prototype.get_image = function() {
      if (!this.has_image) {
        return null;
      } else {
        return this.image;
      }
    };
    return Label;
  })();
  /*
  The Listview Widget displays a list of items, these items are for example a list of songs.
  The Listview is just the view the items have to be stored in a store.
  
  
  events: ['row-activated']
  */

  tree.ui.Listview = (function() {
    __extends(Listview, tree.ui.Widget);
    function Listview(store) {
      this.on_changed = __bind(this.on_changed, this);
      this.update = __bind(this.update, this);
      var columns, field, th, tr, value;
      Listview.__super__.constructor.apply(this, arguments);
      if (!(store != null)) throw new TypeError('store must not be null');
      this.store = store;
      this.htmlelem = document.createElement('table');
      this.htmlelem.className = 'tree-list-view';
      tr = document.createElement('tr');
      this.htmlelem.appendChild(tr);
      columns = store.get_model();
      for (field in columns) {
        value = columns[field];
        if (value !== tree.ui.TYPES.object) {
          th = document.createElement('th');
          tr.appendChild(th);
          th.innerHTML = field;
        }
      }
      this.store.connect('changed', this.on_changed);
      this.selected = null;
    }
    Listview.prototype.get_store = function() {
      return this.store;
    };
    Listview.prototype.update = function() {
      var firstChild, i, row, rows, self, td, tr, _i, _len, _ref;
      firstChild = this.htmlelem.firstChild;
      while (this.htmlelem.childNodes.length > 0) {
        this.htmlelem.removeChild(this.htmlelem.firstChild);
      }
      this.htmlelem.appendChild(firstChild);
      for (i = 0, _ref = this.store.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
        tr = document.createElement('tr');
        tr.className = 'tree-listview-cell';
        tr.index = i;
        self = this;
        tr.onclick = function(event) {
          if (self.selected != null) {
            self.selected.className = 'tree-listview-cell';
          }
          self.selected = this;
          self.selected.className = 'tree-listview-cell-selected';
          return self.emit('row-activated', {
            index: this.index
          });
        };
        this.htmlelem.appendChild(tr);
        rows = this.store.get_values()[i];
        for (_i = 0, _len = rows.length; _i < _len; _i++) {
          row = rows[_i];
          td = document.createElement('td');
          td.innerHTML = row;
          tr.appendChild(td);
        }
      }
      return this;
    };
    Listview.prototype.on_changed = function(widget, evt, args) {
      return this.update();
    };
    return Listview;
  })();
  /*
  
  call functions async
  
  you can also specify a callback that gets the return value as param
  */

  tree.async.async_call = function(func, callback) {
    if (callback) {
      return setTimeout((function() {
        var ret;
        ret = func();
        return callback(ret);
      })(), 1);
    } else {
      return setTimeout((function() {
        return func();
      })(), 1);
    }
  };
  /*
  
  The text widget is used for multiline text input.
  events: ['changed'],
  */

  tree.ui.TextView = (function() {
    __extends(TextView, tree.ui.Widget);
    function TextView() {
      this.button_release = __bind(this.button_release, this);      TextView.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('textarea');
      this.htmlelem.className = 'tree-textarea';
      this.htmlelem.addEventListener('keyup', this.button_release);
      this.rows = this.htmlelem.rows;
      this.cols = this.htmlelem.cols;
    }
    TextView.prototype.button_release = function(widget, event) {
      return this.emit('changed', {
        value: this.htmlelem.value
      });
    };
    TextView.prototype.get_text = function() {
      return this.htmlelem.value;
    };
    TextView.prototype.set_text = function(text) {
      return this.htmlelem.value = text;
    };
    TextView.prototype.set_row = function(rows) {
      this.rows = rows;
      return this.htmlelem.rows = rows;
    };
    TextView.prototype.get_rows = function() {
      return this.rows;
    };
    TextView.prototype.set_cols = function(cols) {
      this.cols = cols;
      return this.htmlelem.cols = cols;
    };
    TextView.prototype.get_cols = function() {
      return this.cols;
    };
    return TextView;
  })();
  tree.unittest.loggers.ConsoleLogger = (function() {
    __extends(ConsoleLogger, tree.BaseObject);
    function ConsoleLogger() {
      ConsoleLogger.__super__.constructor.apply(this, arguments);
    }
    ConsoleLogger.prototype.write = function(data) {
      return console.log(data);
    };
    ConsoleLogger.prototype.error = function(data) {
      return console.error(data);
    };
    return ConsoleLogger;
  })();
  /*
  events: ['changed']
  */

  tree.ui.Entry = (function() {
    __extends(Entry, tree.ui.Widget);
    function Entry() {
      this.button_release = __bind(this.button_release, this);      Entry.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('input');
      this.htmlelem.type = 'text';
      this.htmlelem.className = 'tree-entry';
      this.connect('button-release', this.button_release);
    }
    Entry.prototype.button_release = function(widget, evt) {
      return this.emit('changed', {
        value: this.htmlelem.value
      });
    };
    Entry.prototype.set_password = function(pwd) {
      if (pwd) {
        if (!(typeof password !== "undefined" && password !== null)) {
          this.htmlelem.value = '';
          this.password = pwd;
          return this.htmlelem.type = 'password';
        }
      } else {
        if (this.password != null) {
          this.htmlelem.value = '';
          this.password = pwd;
          return this.htmlelem.type = 'text';
        }
      }
    };
    Entry.prototype.set_text = function(text) {
      return this.htmlelem.value = text;
    };
    Entry.prototype.get_text = function() {
      return this.htmlelem.value;
    };
    return Entry;
  })();
  tree.io.formats.json = {};
  tree.io.formats.json.dump = function(data) {
    return JSON.stringify(data);
  };
  tree.io.formats.json.load = function(data) {
    return JSON.parse(data);
  };
  tree.ui.Table = (function() {
    __extends(Table, tree.ui.Container);
    function Table(homogenous) {
      this.update = __bind(this.update, this);
      var _ref;
      Table.__super__.constructor.apply(this, arguments);
      this.homogenous = homogenous;
      if ((_ref = this.homogenous) == null) this.homogenous = true;
      this.connect('update', this.update);
      this.htmlelem = document.createElement('table');
      this.htmlelem.className = 'tree-table-layout';
      this.children = [];
    }
    Table.prototype.update = function(evt) {
      var child, h, max_x, max_y, row, tr, w, widget, x, y, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3;
      while (this.htmlelem.hasChildNodes()) {
        while (this.htmlelem.childNodes.length >= 1) {
          this.htmlelem.removeChild(this.htmlelem.firstChild);
        }
      }
      max_x = 0;
      max_y = 0;
      this.rows = [];
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        widget = child[0];
        x = child[1];
        y = child[2];
        w = child[3];
        h = child[4];
        if (x > max_x) max_x = x;
        if (y > max_y) max_y = y;
      }
      for (y = 0; 0 <= max_y ? y <= max_y : y >= max_y; 0 <= max_y ? y++ : y--) {
        tr = document.createElement('tr');
        this.rows.push(tr);
        for (x = 0; 0 <= max_x ? x <= max_x : x >= max_x; 0 <= max_x ? x++ : x--) {
          tr.appendChild(document.createElement('td'));
        }
      }
      _ref2 = this.rows;
      for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
        row = _ref2[_j];
        this.htmlelem.appendChild(row);
      }
      _ref3 = this.children;
      for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
        child = _ref3[_k];
        widget = child[0];
        x = child[1];
        y = child[2];
        w = child[3];
        h = child[4];
        row = this.rows[y];
        row.childNodes[x].style.width = w;
        row.childNodes[x].setAttribute('valign', 'top');
        row.childNodes[x].style.height = h;
        row.childNodes[x].appendChild(widget.show());
      }
      return null;
    };
    Table.prototype.add = function(widget, x, y, w, h) {
      this.children.push([widget, x, y, w, h]);
      if (this.exposed) this.emit('update', {});
      return widget.parent = this;
    };
    Table.prototype.remove = function(widget) {
      var child, removed, _i, _len, _ref;
      removed = false;
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        if (child[0] === widget) {
          this.children = this.children.remove(child);
          removed = true;
        }
      }
      if (this.exposed) return this.emit('update', {});
    };
    Table.prototype.show = function() {
      var child, h, max_x, max_y, row, tr, w, widget, x, y, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3;
      max_x = 0;
      max_y = 0;
      this.rows = [];
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        widget = child[0];
        x = child[1];
        y = child[2];
        w = child[3];
        h = child[4];
        if (x > max_x) max_x = x;
        if (y > max_y) max_y = y;
      }
      for (y = 0; 0 <= max_y ? y <= max_y : y >= max_y; 0 <= max_y ? y++ : y--) {
        tr = document.createElement('tr');
        this.rows.push(tr);
        for (x = 0; 0 <= max_x ? x <= max_x : x >= max_x; 0 <= max_x ? x++ : x--) {
          tr.appendChild(document.createElement('td'));
        }
      }
      _ref2 = this.rows;
      for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
        row = _ref2[_j];
        this.htmlelem.appendChild(row);
      }
      _ref3 = this.children;
      for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
        child = _ref3[_k];
        widget = child[0];
        x = child[1];
        y = child[2];
        w = child[3];
        h = child[4];
        row = this.rows[y];
        row.childNodes[x].style.width = w;
        row.childNodes[x].setAttribute('valign', 'top');
        row.childNodes[x].style.height = h;
        row.childNodes[x].appendChild(widget.show());
      }
      return Table.__super__.show.apply(this, arguments);
    };
    return Table;
  })();
  tree.ui.Window = (function() {
    function Window() {}
    Window.set_title = function(title) {
      return document.title = title;
    };
    Window.show = function(widget) {
      return document.body.appendChild(widget.show());
    };
    return Window;
  })();
  /*
  
  events: ['added', 'removed'],
  */

  tree.ui.Rect = (function() {
    __extends(Rect, tree.BaseObject);
    function Rect(x, y, width, height) {
      var BORDER;
      Rect.__super__.constructor.apply(this, arguments);
      BORDER = 0;
      this.x = parseInt(x);
      this.y = parseInt(y);
      this.width = parseInt(width) + BORDER;
      this.height = parseInt(height) + BORDER;
    }
    Rect.prototype.top = function() {
      return this.y;
    };
    Rect.prototype.bottom = function() {
      return this.y + this.height;
    };
    Rect.prototype.left = function() {
      return this.x;
    };
    Rect.prototype.right = function() {
      return this.x + this.width;
    };
    Rect.prototype.collides = function(x, y) {
      if ((this.left() < x && x < this.right()) && (this.top() < y && y < this.bottom())) {
        return true;
      }
      return false;
    };
    return Rect;
  })();
  tree.unittest.TestSuite = (function() {
    __extends(TestSuite, tree.BaseObject);
    function TestSuite() {
      TestSuite.__super__.constructor.apply(this, arguments);
      this.tests = [];
    }
    TestSuite.prototype.add_test = function(test) {
      return this.tests.push(test);
    };
    TestSuite.prototype.run = function() {
      var test, _i, _len, _results;
      _results = [];
      for (_i = 0, _len = tests.length; _i < _len; _i++) {
        test = tests[_i];
        _results.push(test.run());
      }
      return _results;
    };
    return TestSuite;
  })();
  /*
  A Button is used to emit some action when it is pressed.
  
  You will mostly create it, put it into the layout and connect to the 'clicked' event like:
  
  var b = new Button('press me');
  b.connect('clicked', function(widget, event)
  {
      console.log('clicked');
  });
  
  events: ['clicked']
  */

  tree.ui.Button = (function() {
    __extends(Button, tree.ui.Widget);
    function Button(text) {
      Button.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('button');
      this.htmlelem.className = 'tree-button';
      if (text == null) text = '';
      this.set_text(text);
      this.has_image = false;
      this.image = null;
    }
    Button.prototype.set_text = function(text) {
      this.has_image = false;
      this.text = text;
      return this.htmlelem.innerHTML = this.text;
    };
    Button.prototype.set_image = function(image) {
      this.has_image = true;
      this.image = image;
      return this.htmlelem.innerHTML = this.image.show();
    };
    return Button;
  })();
  tree.io.formats.xml = {};
  tree.io.formats.xml.dump = function(data) {
    var serializer;
    serializer = new XMLSerializer;
    return serializer.serializeToString(data);
  };
  tree.io.formats.xml.load = function(data) {
    var parser;
    parser = new DOMParser;
    return parser.parseFromString(data, 'text/xml');
  };
  /*
  give two filenames to this file
  */

  tree.io.formats.xml.applyXSLT = function(xml, xslt) {
    var args, result, xlst, xsltProcessor;
    args = {
      method: tree.io.ajax.REQUEST_METHODS.GET,
      async: false,
      type: tree.io.ajax.DATA_FORMAT.xml
    };
    xml = tree.io.ajax.xhr(xml, args);
    xlst = tree.io.ajax.xhr(xslt, args);
    xsltProcessor = new XSLTProcessor;
    xsltProcessor.importStylesheet(xslt);
    result = xsltProcessor.transformToFragment(xml, document);
    return result;
  };
  /*
  events: ['changed']
  */

  tree.ui.RadioGroup = (function() {
    __extends(RadioGroup, tree.ui.Widget);
    function RadioGroup() {
      this.htmlelem = document.createElement('form');
      this.htmlelem.className = 'tree-radio-group';
      this.children = [];
    }
    RadioGroup.prototype.add = function(child) {
      if (!child instanceof tree.ui.RadioButton) {
        throw new TypeError('you can only put RadioButtons inside a RadioGroup');
      }
      return this.children.push(child);
    };
    RadioGroup.prototype.show = function() {
      var child, _i, _len, _ref;
      RadioGroup.__super__.show.apply(this, arguments);
      _ref = this.children;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        child = _ref[_i];
        this.htmlelem.appendChild(child.show());
      }
      return this.htmlelem;
    };
    return RadioGroup;
  })();
  tree.ui.RadioButton = (function() {
    __extends(RadioButton, tree.ui.Widget);
    function RadioButton(text) {
      this._on_click = __bind(this._on_click, this);      RadioButton.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('div');
      this.htmlelem.className = 'tree-radio-button';
      this.radio = document.createElement('input');
      this.radio.value = text;
      this.radio.name = 'tree-standard';
      this.label = document.createElement('label');
      this.label.innerHTML = text;
      this.radio.type = 'radio';
      this.htmlelem.appendChild(this.label);
      this.htmlelem.appendChild(this.radio);
      this.radio.onclick = this._on_click;
    }
    RadioButton.prototype._on_click = function(widget, event) {
      return this.emit('changed', this.radio.checked);
    };
    RadioButton.prototype.set_text = function(text) {
      return this.label.innerHTML = text;
    };
    return RadioButton;
  })();
  tree.io.rpc.XML_Proxy = (function() {
    __extends(XML_Proxy, tree.io.rpc.Proxy);
    /*
    	Proxy for xmlrpc server methods.
    	For the standard look here: http://www.xmlrpc.com/spec.
    	
    	It also needs theese extensions:
    	
    	http://xmlrpc-c.sourceforge.net/introspection.html
    	http://ontosys.com/xml-rpc/extensions.php
    	
    	events: ['error-occured'],
    */

    function XML_Proxy(url) {
      XML_Proxy.__super__.constructor.call(this, url);
      this.content_type = tree.io.ajax.DATA_FORMAT.xml;
    }
    XML_Proxy.prototype.parse_response = function(data) {
      var error, member, members, name, node, param, params, parse_array, parse_object, parse_scalar, response, value, xml, _i, _j, _k, _len, _len2, _len3, _ref;
      xml = tree.io.formats.xml.load(data);
      params = xml.getElementsByTagName('param');
      response = [];
      parse_scalar = function(node) {
        if (node.firstChild.nodeName === 'int') {
          return parseInt(node.firstChild.firstChild.nodeValue);
        } else if (node.firstChild.nodeName === 'double') {
          return parseFloat(node.firstChild.firstChild.nodeValue);
        } else if (node.firstChild.nodeName === 'string') {
          return node.firstChild.firstChild.nodeValue;
        } else if (node.firstChild.nodeName === 'boolean') {
          if (node.firstChild.firstChild.nodeValue === '1') {
            return true;
          } else {
            return false;
          }
        } else if (node.firstChild.nodeName === 'nil') {
          return null;
        }
      };
      parse_array = function(node) {
        var item, _i, _len, _ref, _results;
        _ref = node.firstChild.childNodes;
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          item = _ref[_i];
          _results.push(parse_object(item));
        }
        return _results;
      };
      parse_object = function(param) {
        var node, _i, _len, _ref;
        node = null;
        _ref = param.childNodes;
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          node = _ref[_i];
          if (param.childNodes[i].nodeName !== '#text') {
            node = param.childNodes[i];
            break;
          }
        }
        if (node.nodeName === 'value') {
          return parse_scalar(node);
        } else if (node.nodeName === 'array') {
          return parse_array(node);
        }
      };
      /*
              fault:
              
              <fault>
                  <value>
                      <struct>
                          <member>
                              <name>faultCode</name>
                              <value><int>4</int></value>
                          </member>
                          <member>
                              <name>faultString</name>
                              <value><string>Too many parameters.</string></value>
                          </member>
                      </struct>
                  </value>
              </fault>
      */

      if (params.length === 0) {
        error = {};
        members = xml.getElementsByTagName('member');
        for (_i = 0, _len = members.length; _i < _len; _i++) {
          member = members[_i];
          name = '';
          value = '';
          _ref = member.childNodes;
          for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
            node = _ref[_j];
            if (member.childNodes[i2].nodeName === 'name') {
              name = node.firstChild.nodeValue;
            } else if (member.childNodes[i2].nodeName === 'value') {
              value = node.firstChild.firstChild.nodeValue;
            }
          }
          error[name] = value;
        }
        this.emit('error-occured', error);
        return error;
      }
      for (_k = 0, _len3 = params.length; _k < _len3; _k++) {
        param = params[_k];
        response.push(parse_object(param));
      }
      return response;
    };
    XML_Proxy.prototype.create_request = function(name, params) {
      var format_array, format_hash, format_obj, format_scalar, request, value, _i, _len;
      format_obj = function(value) {
        var type;
        type = typeof value;
        if (type === 'string' || type === 'number' || type === 'boolean' || value === null) {
          return format_scalar(value);
        } else {
          if (value instanceof Array) {
            return format_array(value);
          } else {
            return format_hash(value);
          }
        }
      };
      format_hash = function(value) {
        var key, t, val;
        t = '<struct>';
        for (key in value) {
          val = value[key];
          t += '<member>';
          t += '<name>' + key + '</name>';
          t += format_obj(val);
          t += '</member>';
        }
        return t + '</struct>';
      };
      format_array = function(value) {
        var t, val, _i, _len;
        t = '<array><data>';
        for (_i = 0, _len = value.length; _i < _len; _i++) {
          val = value[_i];
          t += format_obj(val);
        }
        t += '</array></data>';
        return t;
      };
      format_scalar = function(value) {
        var val;
        if ((typeof value) === 'number') {
          if (String(value).indexOf('.') !== -1) {
            return '<value><double>' + String(value + '</double></value>');
          } else {
            return '<value><int>' + String(value + '</int></value>');
          }
        } else if ((typeof value) === 'string') {
          return "<value><string>" + value + "</string></value>";
        } else if ((typeof value) === 'boolean') {
          val = value;
          if (val) {
            value = 1;
          } else {
            value = 0;
          }
          return "<value><boolean>" + value + "</boolean></value>";
        } else if (value === null) {
          return '<value><nil/></value>';
        } else {
          throw 'invalid type given';
        }
      };
      request = '<?xml version="1.0"?><methodCall>';
      request += "<methodName>" + name + "</methodName>";
      request += '<params>';
      for (_i = 0, _len = params.length; _i < _len; _i++) {
        value = params[_i];
        request += '<param>';
        request += format_obj(value);
        request += '</param>';
      }
      request += '</params></methodCall>';
      return request;
    };
    return XML_Proxy;
  })();
  tree.unittest._suite = new tree.unittest.TestSuite;
  tree.unittest.main = function() {
    return tree.unittest._suite.run();
  };
  tree.ui.CheckButton = (function() {
    __extends(CheckButton, tree.ui.Widget);
    function CheckButton(text) {
      CheckButton.__super__.constructor.apply(this, arguments);
      this.htmlelem = document.createElement('form');
      this.htmlelem.className = 'tree-check-button';
      this.check = document.createElement('input');
      this.check.value = text;
      this.check.name = 'tree-standard';
      this.label = document.createElement('label');
      this.label.innerHTML = text;
      this.check.type = 'checkbox';
    }
    CheckButton.is_checked = function() {
      return this.htmlelem.checked;
    };
    return CheckButton;
  })();
  Array.prototype.contains = function(obj) {
    var item, _i, _len;
    for (_i = 0, _len = this.length; _i < _len; _i++) {
      item = this[_i];
      if (item === obj) return true;
    }
    return false;
  };
  Array.prototype.remove = function(obj) {
    var item, _i, _len, _results;
    _results = [];
    for (_i = 0, _len = this.length; _i < _len; _i++) {
      item = this[_i];
      if (item !== obj) _results.push(item);
    }
    return _results;
  };
  Array.prototype.indexOf = function(obj) {
    var i, _ref;
    for (i = 0, _ref = this.length; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
      if (this[i] === obj) return i;
    }
    return -1;
  };
  Array.prototype.map = function(func) {
    var item, _i, _len, _results;
    _results = [];
    for (_i = 0, _len = this.length; _i < _len; _i++) {
      item = this[_i];
      _results.push(func(item));
    }
    return _results;
  };
  /*
  
  The Store holds values for the listview.
  */

  tree.ui.TYPES = {
    string: 1,
    number: 2,
    image: 3,
    radio: 4,
    object: 5
  };
  /*
  var s = new Store(
  {
      title: TYPES.string,
      
  });
  
  Stores are used to store data for the listview.
  You have to specify the types of the columns first.
  After creating the widgets, you can add elements by using tree.ui.Store.append:
  
  s.append(['string number one']);
  
  You can access elements by using tree.ui.Store.index:
  
  s.index(0);
  
  events: ['changed']
  */

  tree.ui.Store = (function() {
    __extends(Store, tree.BaseObject);
    function Store(columns) {
      var field;
      Store.__super__.constructor.apply(this, arguments);
      this.model = columns;
      this.len = 0;
      for (field in columns) {
        this.len += 1;
      }
      this.values = [];
      this.length = 0;
    }
    /*
        append values, the values must be in an array, also if the store contains just one element
    */

    Store.prototype.append = function(value) {
      if (value.length !== this.len) {
        throw new TypeError('invalid length for liststore');
      } else {
        this.length += 1;
        this.values.push(value);
        return this.emit('changed', {});
      }
    };
    /*
        access rows by their index
    */

    Store.prototype.index = function(i) {
      return this.values[i];
    };
    Store.prototype.get_values = function() {
      return this.values;
    };
    Store.prototype.get_model = function() {
      return this.model;
    };
    return Store;
  })();
}).call(this);
